﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;

namespace ManagoMes.Read.API.Applications.ProductionScheduling
{
    public class SchedulingDisplayHtmlhandler : IRequestHandler<SchedulingDisplayHtmlCommond, ResultsDTO<givebirth>>
    {

        private readonly IBateRepository<givebirth> _givebirth;

        public SchedulingDisplayHtmlhandler(IBateRepository<givebirth> givebirth)
        {
            _givebirth = givebirth;
        }

        public async Task<ResultsDTO<givebirth>> Handle(SchedulingDisplayHtmlCommond request, CancellationToken cancellationToken)
        {

            try
            {
                var list = new ResultsDTO<givebirth>() { Code = 0 };
                var str = "select * from givebirth";
                var Empty = new givebirth();
                DapperHelper dapperHelper = new DapperHelper();
                var lists = _givebirth.GetAll(str, Empty, dapperHelper.RBACRead).ToList();
                lists = lists.Where(x => x.ProductionTypeid == request.Productionid).ToList();

                list.Data = lists;
                return list;
            }
            catch (Exception)
            {
                throw;
            }
          



        }
    }
}
